﻿using kratos;
using rpc;
using System;
using System.Collections.Generic;
using System.Net.Cache;
using System.Threading;

namespace rpc_bench {
class Program {
  static async void DoTest(IRpc rpc) {
    await rpc.Connect("127.0.0.1", 9888, 1000);
    var prx = Proxy.GetLogin();
    var dyn_prx = Proxy.GetServiceDynamic();
    var start = Util.GetNowMS();
    HashSet<string> set_string = new HashSet<string>();
    set_string.Add("a");
    set_string.Add("b");
    long count = 0;
    while (true) {
      try {
        var id = await prx.login("123", "123", 2000);
        Console.WriteLine($"id:{id}");
        var ret_string = await dyn_prx.method2(1, set_string, 100, 1000);
        Console.WriteLine($"ret_string:{ret_string}, count: {count++}");
      } catch {
      }
    }
  }

  static void Main(string[] args) {
    var rpc = RpcFactory.create();
    DoTest(rpc);
    while (true) {
      rpc.Update();
      //Thread.Sleep(100);
    }
  }
}
}
